home *** CD-ROM | disk | FTP | other *** search
/ PsL Monthly 1993 December / PSL Monthly Shareware CD-ROM (December 1993).iso / prgmming / dos / pascal / gsdbloo.exe / DEMOE003.PAS < prev    next >
Pascal/Delphi Source File  |  1992-02-24  |  4KB  |  118 lines

  1. program DemoE003;
  2. {------------------------------------------------------------------------------
  3.                               DBase File Editor
  4.                               Expanded Sample 3
  5.                                  Demo Program
  6.  
  7.        Copyright (c)  Richard F. Griffin
  8.  
  9.        10 February 1992
  10.  
  11.        102 Molded Stone Pl
  12.        Warner Robins, GA  31088
  13.  
  14.        -------------------------------------------------------------
  15.        Display and edit all record fields on-screen using an index.
  16.        This includes the memo field.
  17.  
  18.        **********  Not For Use in a TurboVision Environment  **********
  19.  
  20.        If it does not already exist, the DEMOE3.DBF file will be created
  21.        by using the MakeTestData procedure in GS_GENF.PAS.
  22.  
  23.        All fields in the dBase record will be displayed on-screen using
  24.        the FieldDisplay procedure in GS_dBFld_Objt. They can be modified
  25.        and stored back to the dBase file using the FieldAccept procedure.
  26.  
  27.        Note that when the index key field LASTNAME is changed, the next
  28.        record that displays is the record following the NEW key position.
  29.  
  30. -------------------------------------------------------------------------------}
  31. uses
  32.    CRT,
  33.    DOS,
  34.    GS_KeyI,
  35.    GS_dBFld,
  36.    GS_dBase,
  37.    GS_FileH,
  38.    GS_GenF;
  39. var
  40.    MyFile  : GS_dBFld_Objt;
  41.    CkFile  : file;
  42.    DumyStr : string;
  43.    NewFile : boolean;
  44.  
  45. procedure DisplayRecord;
  46. begin
  47.   MyFile.FieldDisplay('LASTNAME','Last Name: ',1,1);
  48.    MyFile.FieldDisplay('FIRSTNAME','First Name, Middle Initial: ',1,2);
  49.    MyFile.FieldDisplay('STREET','Street Address: ',1,3);
  50.    MyFile.FieldDisplay('OFFICE','Building, suite, etc: ',1,4);
  51.    MyFile.FieldDisplay('CITY','City: ',1,5);
  52.    MyFile.FieldDisplay('STATE','State: ',1,6);
  53.    MyFile.FieldDisplay('ZIP','Zip Code: ',1,7);
  54.    MyFile.FieldDisplay('TELEPHONE','Telephone Number: ',1,8);
  55.    MyFile.FieldDisplay('BIRTHDATE','Date of Birth: ',1,9);
  56.    MyFile.FieldDisplay('PAYMENT','Payment Amount: ',1,10);
  57.    MyFile.FieldDisplay('PAIDFLAG','Amount Was Paid?: ',1,11);
  58.    MyFile.FieldDisplay('RANDOMNUM','Random Number: ',1,12);
  59.    MyFile.FieldDisplay('COMMENTS','Comments: ',1,13);
  60. end;
  61.  
  62. procedure ModifyRecord;
  63.  
  64.    procedure AcceptRec(FieldName, FieldTitle : string; x, y : integer);
  65.    begin
  66.       DumyStr := MyFile.FieldAccept(FieldName, FieldTitle, x, y);
  67.       if not GS_KeyI_Esc then
  68.          MyFile.FieldPut(FieldName,DumyStr);
  69.    end;
  70.  
  71. begin
  72.    MyFile.RecChanged := false;
  73.   AcceptRec('LASTNAME','Last Name: ',1,1);
  74.    if not GS_KeyI_Esc then AcceptRec('FIRSTNAME',
  75.                                      'First Name, Middle Initial: ',1,2);
  76.    if not GS_KeyI_Esc then AcceptRec('STREET','Street Address: ',1,3);
  77.    if not GS_KeyI_Esc then AcceptRec('OFFICE','Building, suite, etc: ',1,4);
  78.    if not GS_KeyI_Esc then AcceptRec('CITY','City: ',1,5);
  79.    if not GS_KeyI_Esc then AcceptRec('STATE','State: ',1,6);
  80.    if not GS_KeyI_Esc then AcceptRec('ZIP','Zip Code: ',1,7);
  81.    if not GS_KeyI_Esc then AcceptRec('TELEPHONE','Telephone Number: ',1,8);
  82.    if not GS_KeyI_Esc then AcceptRec('BIRTHDATE','Date of Birth: ',1,9);
  83.    if not GS_KeyI_Esc then AcceptRec('PAYMENT','Payment Amount: ',1,10);
  84.    if not GS_KeyI_Esc then AcceptRec('PAIDFLAG','Amount Was Paid?: ',1,11);
  85.    if not GS_KeyI_Esc then AcceptRec('RANDOMNUM','Random Number: ',1,12);
  86.    if not GS_KeyI_Esc then AcceptRec('COMMENTS','Comments: ',1,13);
  87.    if (not GS_KeyI_Esc) and (MyFile.RecChanged) then
  88.       MyFile.PutRec(MyFile.RecNumber);
  89. end;
  90.  
  91.  
  92. begin
  93.    ClrScr;
  94.    if not GS_FileExists(CkFile,'DEMOE3.DBF') then
  95.    begin
  96.       writeln('Creating DEMOE3.DBF');
  97.       MakeTestData('DEMOE3', 20, true);
  98.       writeln('DEMOE3.DBF Created');
  99.       NewFile := true;
  100.       ClrScr;
  101.    end
  102.       else NewFile := false;
  103.    GotoXY(1,15);
  104.    write('Press ESC to stop, any other key to continue');
  105.    MyFile.Init('DEMOE3');
  106.    MyFile.Open;
  107.    if NewFile then MyFile.IndexTo('DEMOE3','LASTNAME');
  108.    MyFile.Index('DEMOE3');
  109.    MyFile.GetRec(Top_Record);
  110.    while (not MyFile.File_EOF) and (not GS_KeyI_Esc) do
  111.    begin
  112.       DisplayRecord;
  113.       ModifyRecord;
  114.       MyFile.GetRec(Next_Record);
  115.    end;
  116.    MyFile.Close;
  117. end.
  118.